<template>
  <div>
    <bbw-table
            :tableData.sync="tableData"
            @onFinish="onFinish"
            :header="header"
            title="管理员表"
    >

    </bbw-table>
  </div>
</template>

<script>
    import api from '../utils/api'
    import {get, post} from '../utils/request'
export default {
    data(){
        return {
            tableData:[],
            column:[

            ],
            header:[
                {
                    label: '邮箱',
                    value:'email'
                },
                {
                    label: '密码',
                    value: 'password',
                    // defaultValue: '******'
                },
                {
                    label: '是否管理员',
                    value:'root',
                    type:'switch'
                },
                {
                    label: '创建日期',
                    value:'create_at',
                    type:'text'
                }

                ]
        }
    },
    props: {
     // msg: String
    },
    mounted(){
        this.getUser()
    },
    methods:{
        getUser(){
            get(api.getUser).then(res=>{
                 this.tableData = res.data
            }).catch(err=>{

            })
        },
        onFinish(data){
            post(api.manageUser,data).then(res=>{
                this.$message(res.msg)
                this.getUser()
            }).catch(err=>{
                this.getUser()
                this.$message(err.msg||'提交错误')
            })
        }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
